# -*- coding: utf-8 -*-
# Import future modules
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

# Import built-in modules
import signal

# Import third-party modules
from Qt import QtCore
from Qt import QtWidgets

from test2.graph.left_widget import TitleToolBar

signal.signal(signal.SIGINT, signal.SIG_DFL)

# Import built-in modules
import importlib
import os

# Import third-party modules
import Qt

# Qt.py global variable for preferred Qt binding
# os.environ["QT_PREFERRED_BINDING"] = "PyQt4;PyQt5;PySide;PySide2"
# For Houdini hython.exe
# os.environ["QT_QPA_PLATFORM_PLUGIN_PATH"] = r"E:\Houdini18\bin\Qt_plugins\platforms"


print(Qt.__binding__)

# Import built-in modules
import codecs

# Import local modules
from dayu_widgets import dayu_theme
from dayu_widgets.dock_widget import MDockWidget
from dayu_widgets.item_view_set import MItemViewSet


class PyFlowGraph(QtWidgets.QMainWindow):
    def __init__(self, parent=None):
        super(PyFlowGraph, self).__init__(parent)
        self._init_ui()

    def _init_ui(self):
        self.text_edit = QtWidgets.QTextEdit()
        self.stacked_widget = QtWidgets.QStackedWidget()
        list_widget = MItemViewSet(view_type=MItemViewSet.ListViewType)
        list_widget.set_header_list([{"key": "name", "label": "Name", "icon": "list_view.svg"}])
        test_widget = MDockWidget("")
        test_widget.setFeatures( MDockWidget.DockWidgetMovable)
        test_widget.setTitleBarWidget(TitleToolBar())
        test_widget.setWidget(list_widget)
        self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, test_widget)
        self.setCentralWidget(self.stacked_widget)



if __name__ == "__main__":
    # Import local modules
    from dayu_widgets import dayu_theme
    from dayu_widgets.qt import application

    with application() as app:
        test = PyFlowGraph()
        test.setFixedWidth(800)
        test.setFixedHeight(500)
        dayu_theme.set_theme("light")
        dayu_theme.apply(test)
        test.show()
